/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package edu.asu.cse360.client.util;

import edu.asu.cse360.client.action.ChangeLanguage;
import edu.asu.cse360.client.action.EnterCustomerModeAction;
import edu.asu.cse360.client.action.OpenUserGuide;
import edu.asu.cse360.client.ui.frame.AppFrame;
import edu.asu.cse360.client.action.LogoutAction;
import java.awt.BorderLayout;
import java.util.List;
import javax.swing.JFrame;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.JPanel;

/**
 * This class configures the frame for all windows
 * @author nadimhoque
 */
public abstract class AppConfiguration {
    protected boolean hasConfiguredAppFrame = false;

    /**
     * Configures the app frame
     * 
     * @param frame
     */
    public abstract void configure(AppFrame frame);

    public void reset(AppFrame frame){
        frame.setJMenuBar(null);
    }


    /**
     * Adds the menu bar to the app frame
     *
     * @param frame
     */
    protected void addMenuBar(AppFrame frame) {
        frame.setJMenuBar(null);
        JMenuBar menuBar = new JMenuBar();
        for(JMenu menu : getMenus(frame)){
            menuBar.add(menu);
        }
        frame.setJMenuBar(menuBar);
    }

    protected abstract List<JMenu> getMenus(AppFrame frame);

    protected JMenu getHelpMenu() {
        JMenu employeeHelp = new JMenu("Help");
        employeeHelp.add(new JMenuItem(new OpenUserGuide()));
        return employeeHelp;
    }

    protected JMenu getAdminMenu(AppFrame frame) {
        JMenu logout = new JMenu("Admin");
        logout.add(new JMenuItem(new EnterCustomerModeAction(frame)));
        logout.add(new JMenuItem(new LogoutAction()));
        return logout;
    }

   /* protected JMenu getSettingsMenu(){
        JMenu settingsMenu = new JMenu("Settings");
        settingsMenu.add(new JMenuItem(new ChangeLanguage()));
        return settingsMenu;
    }*/

    protected void addPanel(JPanel panel, JPanel newPanel) {
        panel.setLayout(new BorderLayout());
        panel.add(newPanel, BorderLayout.CENTER);
        panel.revalidate();
    }
}
